package com.cwd.arm.common.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yan on 21-11-28.
 */
public enum NodeTypeEnum {
    PRE_AMOUNT("PRE_AMOUNT", "预付款"),
    ENSURE_AMOUNT("ENSURE_AMOUNT", "保证金"),
    PROGRESS_PAY("PROGRESS_PAY", "进度款"),
    HONOR("CLOSE_PAY", "结算款"),
    QA_AMOUNT("QA_AMOUNT", "质保金");


    String code; // 状态编号
    String name; //状态名称

    NodeTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getName(String code) {
        for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) {
            if (nodeTypeEnum.getCode().equals(code)) {
                return nodeTypeEnum.getName();
            }
        }
        return null;
    }

    public static String getCode(String name) {
        for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) {
            if (nodeTypeEnum.getName().equals(name)) {
                return nodeTypeEnum.getCode();
            }
        }
        return null;
    }

    public static List<String> getNameList() {
        List<String> nameList = new ArrayList<>();
        for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) {
            nameList.add(nodeTypeEnum.getName());
        }
        return nameList;
    }

}
